package com.itheima.date;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;

public class datetest03 {
    public static void main(String[] args) {
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDate now = LocalDate.now();
        LocalDate localDate = LocalDate.of(2021, 12, 8);
        LocalDateTime localDateTime = LocalDateTime.of(2020, 11, 12, 13, 14, 15);
        LocalDateTime localDateTime1 = LocalDateTime.of(2021, 12, 1, 3, 24, 19);
        Duration duration = Duration.between(localDateTime, localDateTime1);
        System.out.println(duration.toDays());
        System.out.println(duration.toMillis());
        System.out.println(duration.toNanos());
        System.out.println(duration.toHours());
        System.out.println(duration.toMinutes());
        System.out.println(duration.toString());
        //        System.out.println(localDateTime.plusYears(1));
//        System.out.println(localDateTime.minusYears(1));
//        System.out.println(localDateTime.plusWeeks(2));
//        System.out.println(localDateTime.withYear(2032));
//        System.out.println(localDateTime.withDayOfYear(362));
//        System.out.println(Period.between(now, localDate));
//        Period period = Period.between(now, localDate);
//        System.out.println(period.getYears());
//        System.out.println(period.toTotalMonths());



    }
}
